﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;

namespace Escape
{
    class GridBlock: SpriteBlock
    {

        bool isClosed = true;
        SoundEffect sound;

        float r;

        public GridBlock(Vector3 position, direction dir)
            : base(position, dir, Basic.content.Load<Texture2D>("Textures\\gitter"))
        {
            sound = Basic.content.Load<SoundEffect>("Sounds\\blockDestroy");
        }

        public override void use()
        {

            if (ItemBar.currentItem is FistItem && isClosed && Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                Nullable<float> result = GameScreen.pickRay.Intersects(box);
                if (result.HasValue && result.Value < 1.0f)
                {
                    sound.Play();
                    isClosed = false;
                    collision = false;
                    tex = Basic.content.Load<Texture2D>("Textures\\gitterBroken");
                }
            }
            base.use();
        }
    }
}
